﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 测试工具
{
    public partial class UserControl1 : UserControl
    {

        public static UserControl2[] userControl12;
        public static UserControl3 userControl13;
        public static int columns = 4;
        public static int row = 1;
        public static int test_num = 0;
        public static int test_ng_num = 0;
        public UserControl1()
        {
            InitializeComponent();
            UpdateUI();
        }

        private void UpdateUI()
        {
            this.Controls.Clear();  //清空当前容器中的控件

            userControl13 = new UserControl3();
            userControl13.Location = new System.Drawing.Point(this.Size.Width - 160, 0);
            userControl13.Size = new Size(160, Form1.splitContainer1.Size.Height);
            this.Controls.Add(userControl13);

            int wScale = (this.Size.Width-160) / columns;//一个测试单元的宽度
            int hScale = this.Size.Height / row;//一个测试单元的高度

            userControl12 = new UserControl2[columns* row];

            for (int i = 0; i < row; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    userControl12[i * columns + j] = new UserControl2();
                    userControl12[i * columns + j].Location = new System.Drawing.Point(j * wScale, i * hScale);
                    userControl12[i * columns + j].Size = new Size(wScale, hScale);
                    this.Controls.Add(userControl12[i * columns + j]);
                    userControl12[i * columns + j].UpdateSerial();
                }
            }
        }

        private void UserControl1_SizeChanged(object sender, EventArgs e)
        {
            this.Size = new System.Drawing.Size(Form1.splitContainer1.Size.Width, Form1.splitContainer1.Size.Height);
            UpdateUI();
        }
    }
}
